How to retrieve DOORS module which has current focus?

Does anyone has an idea how it is possible to determine that module of all open and visible modules which

has the current focus (focus got either by mouse or Keyboard)?

Until so far, I could not find anything.

Note: The command current() does not work for that issue.


MarcoLuk - Tue Jan 05 04:35:18 EST 2016

Re: How to retrieve DOORS module which has current focus?
Mathias Mamsch - Tue Jan 05 11:49:28 EST 2016

Well if current() does not work for you it is possible you are out of luck - what are you trying to achieve? Regards, Mathias

Re: How to retrieve DOORS module which has current focus?
MarcoLuk - Tue Jan 05 11:57:29 EST 2016

Mathias Mamsch - Tue Jan 05 11:49:28 EST 2016

Well if current() does not work for you it is possible you are out of luck - what are you trying to achieve? Regards, Mathias

Hello Mathias,

 

I have a DXL-written application which shall transfer and write data to the module which got the last Focus. We can have the situation, that more than one module is being opened at the same time.

But we only want to transfer these data to that selected module (= which got the last focus e.g. by clicking it by mouse or ALT+TAB).

Re: How to retrieve DOORS module which has current focus?
Mathias Mamsch - Wed Jan 06 03:00:56 EST 2016

MarcoLuk - Tue Jan 05 11:57:29 EST 2016

Hello Mathias,

 

I have a DXL-written application which shall transfer and write data to the module which got the last Focus. We can have the situation, that more than one module is being opened at the same time.

But we only want to transfer these data to that selected module (= which got the last focus e.g. by clicking it by mouse or ALT+TAB).

Well usually I know the situation, that a user will start a DXL script from the Module menu. In this case "current()" will give you the handle to the module from which the script was started. So I am wondering how the user will invoke your DXL application so that the current module is ambiguous?

a) From th Module Menu --> Use current() ... It will reflect the module from which the script was started (see note below)

b) From the Project Explorer Menu --> Use the Module menu instead to remove the ambiguity

c) From Run/DXL --> Use the Module menu instead

d) Over COM?
If your are invoking your application over COM, then your current module will indeed not be set. I used to implement here a quick check that I launch before the main script.

  • Is only one module open? --> Use that one
  • Are there multiple modules opened? --> retrieve all opened modules (for mod in database) and give the user a choice which one he wants to use. Then launch the main script with that module.

I see no other possibility to run a DXL script.

Note

There is a pitfall with the current module, that might confuse you and cause you to really wonder what is going on. You might be using a DXL library that changes the current module (e.g. by reading a config module). If your code looks like that:

#include <myLibrary.inc>

Module mod = current
...

If myLibrary.inc opens a module in global code then the current module will be changed. Easy way to resolve that, save the current module before you call any include.

Not sure if that helps, regards, Mathias

Re: How to retrieve DOORS module which has current focus?
MarcoLuk - Thu Jan 07 04:29:50 EST 2016

Mathias Mamsch - Wed Jan 06 03:00:56 EST 2016

Well usually I know the situation, that a user will start a DXL script from the Module menu. In this case "current()" will give you the handle to the module from which the script was started. So I am wondering how the user will invoke your DXL application so that the current module is ambiguous?

a) From th Module Menu --> Use current() ... It will reflect the module from which the script was started (see note below)

b) From the Project Explorer Menu --> Use the Module menu instead to remove the ambiguity

c) From Run/DXL --> Use the Module menu instead

d) Over COM?
If your are invoking your application over COM, then your current module will indeed not be set. I used to implement here a quick check that I launch before the main script.

  • Is only one module open? --> Use that one
  • Are there multiple modules opened? --> retrieve all opened modules (for mod in database) and give the user a choice which one he wants to use. Then launch the main script with that module.

I see no other possibility to run a DXL script.

Note

There is a pitfall with the current module, that might confuse you and cause you to really wonder what is going on. You might be using a DXL library that changes the current module (e.g. by reading a config module). If your code looks like that:

#include <myLibrary.inc>

Module mod = current
...

If myLibrary.inc opens a module in global code then the current module will be changed. Easy way to resolve that, save the current module before you call any include.

Not sure if that helps, regards, Mathias

Thanks for your detailed information.

Maybe there is a misunderstood: I do not want to determine the current module directly, I want to find out which module of the current visible and open modules got the last focus.

Once I determined the module with the last focus, I can set this module to the current module. That would be no problem.

 

There is a dxl-library function "setFocus(Module m)" available, which sets the window focus to the passed module m.

Analog to this function I would need a "Module getFocus(void)" or similar, which returns that module with has the current window.

 

Re: How to retrieve DOORS module which has current focus?
Mathias Mamsch - Thu Jan 07 05:15:22 EST 2016

MarcoLuk - Thu Jan 07 04:29:50 EST 2016

Thanks for your detailed information.

Maybe there is a misunderstood: I do not want to determine the current module directly, I want to find out which module of the current visible and open modules got the last focus.

Once I determined the module with the last focus, I can set this module to the current module. That would be no problem.

 

There is a dxl-library function "setFocus(Module m)" available, which sets the window focus to the passed module m.

Analog to this function I would need a "Module getFocus(void)" or similar, which returns that module with has the current window.

 

I understood, that you somehow want to emply the focus for good usability of your script. My guess is, that won't fly.

For one its technically non feasible. The other thing is, that I know only very few applications even outside DOORS, that need the concept of "focus" for selecting a target for operation.

You did not give any details, about what the script is going to do and for what the user needs to select a module. If you give us some details, what your application is about, and why you would want to employ the "module that had the focus last" in your application, we can suggest a fitting way to implement what you want in DOORS. 

Most probably you can get the same usability and effect by using one of the DOORS standard ways, like context menus, drag/drop, sync triggers, etc. or simply by starting your script from the target module in the first place (which was where my last point was going at).

Regards, Mathias

Re: How to retrieve DOORS module which has current focus?
MarcoLuk - Thu Jan 07 05:59:02 EST 2016

Mathias Mamsch - Thu Jan 07 05:15:22 EST 2016

I understood, that you somehow want to emply the focus for good usability of your script. My guess is, that won't fly.

For one its technically non feasible. The other thing is, that I know only very few applications even outside DOORS, that need the concept of "focus" for selecting a target for operation.

You did not give any details, about what the script is going to do and for what the user needs to select a module. If you give us some details, what your application is about, and why you would want to employ the "module that had the focus last" in your application, we can suggest a fitting way to implement what you want in DOORS. 

Most probably you can get the same usability and effect by using one of the DOORS standard ways, like context menus, drag/drop, sync triggers, etc. or simply by starting your script from the target module in the first place (which was where my last point was going at).

Regards, Mathias

We have a DXL-written dialog, which shall transfer data (write) into a module. The thing is, that several modules can be opened at one time, but the

data shall written into that module, which the user determines by selecting it e.g. by mouse-click or keyboard shortcut or double-click into an object cell).

The problem is, that the current module does not "update" to that module.

Re: How to retrieve DOORS module which has current focus?
Mathias Mamsch - Thu Jan 07 06:20:56 EST 2016

MarcoLuk - Thu Jan 07 05:59:02 EST 2016

We have a DXL-written dialog, which shall transfer data (write) into a module. The thing is, that several modules can be opened at one time, but the

data shall written into that module, which the user determines by selecting it e.g. by mouse-click or keyboard shortcut or double-click into an object cell).

The problem is, that the current module does not "update" to that module.

Ok, so the easiest way:

a) Why would you not have the user start the script from the target module (using the module menu or the context menu)? In this case you can use current.

b) You can use a simple GUI popup with the currently opened modules (for module in database do ...) where the user can select the module to which he wants to transfer the data. This would probably be the most DOORS like way, to handle the issue, if a) is no option.

c) You could try using a sync trigger, that will fire, when the user selects an object inside one of the open modules.

Regards, Mathias

Re: How to retrieve DOORS module which has current focus?
ducosa - Tue Jun 06 09:34:07 EDT 2017

I know this thread is more than one year old, but for those who are still looking for, this is possible.

This function is not described in the DXL manual :

 

Item it = getSelectedItem

will do the job.

If no selected Item," fullName it" will return "/"

Otherwise fullName it will return the selected item in the DOORS database window.

 

Too bad a lot of function like that are missing in the DXL Manual... ;)

Re: How to retrieve DOORS module which has current focus?
MarcoLuk - Tue Jun 06 10:48:27 EDT 2017

ducosa - Tue Jun 06 09:34:07 EDT 2017

I know this thread is more than one year old, but for those who are still looking for, this is possible.

This function is not described in the DXL manual :

 

Item it = getSelectedItem

will do the job.

If no selected Item," fullName it" will return "/"

Otherwise fullName it will return the selected item in the DOORS database window.

 

Too bad a lot of function like that are missing in the DXL Manual... ;)

Hello ducosa,

 

many thanks for your advice.

Indeed the function "getSelectedItem" is not being documented in my dxl help.

 

I also tested this function and it really Returns the selected item in the DOORS database window.

But I need a function which does not return the selected item in the database window but that currently

loaded and opened module which has the current focus or has been clicked most recently.

Re: How to retrieve DOORS module which has current focus?
ducosa - Tue Jun 06 13:55:22 EDT 2017

MarcoLuk - Tue Jun 06 10:48:27 EDT 2017

Hello ducosa,

 

many thanks for your advice.

Indeed the function "getSelectedItem" is not being documented in my dxl help.

 

I also tested this function and it really Returns the selected item in the DOORS database window.

But I need a function which does not return the selected item in the database window but that currently

loaded and opened module which has the current focus or has been clicked most recently.

My bad I misunderstood.

Yes maybe the only technical solution that I see is:

-create both sync trigger for opening a module OR selecting an object of a module

-use this trigger to set en environment variable (setenv)

-at the begenninb of your transfer script, get back this variable (getenv)

-Then put a confirm box specifying the corresponding module... let's be careful ;)

-Then transfer

 

However, I don't think you can trigger the event "alt Tab" to a module for instance... So this solution is limited, this is why the confirm box is important...